package com.fs.model;

import com.fs.util.FATUtil;
import lombok.*;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
/**
 * 文件夹
 */
public class Folder {

    private String folderName;//文件夹名
    private String type;//文件夹类型
    private int diskNum;//起始盘块号
    private String location;//位置
    private double size;//大小
    private String space;//占用空间
    private Date createTime;//创建时间

    private Folder parent;//父文件夹
    private List<Object> children;//子文件夹
    private Path path;//路径对象

    public Folder(String folderName,String location,int diskNum,Folder parent) {
        this.folderName=folderName;
        this.location=location;
        this.size=0;
        this.space=size+"KB";
        this.createTime=new Date();

        this.diskNum=diskNum;
        this.type= FATUtil.FOLDER;

        this.parent=parent;
        this.setChildren(new ArrayList<>());

    }

    public void addChildren(Object child) {
        children.add(child);
    }
    public boolean hasChild() {
        return children.isEmpty() ? false : true;
    }
    public void removeChildren(Object child) {
        this.children.remove(child);
    }
    public boolean hasParent() {
        return (parent == null) ? false : true;
    }
    public String getCreateTime() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日  HH:mm:ss");
        return format.format(createTime);
    }
}
